package kdd.feature;
import java.sql.*;
import java.util.HashMap;
import java.util.HashSet;

import kdd.lib.Lib;

public class ProjectAbstract {
	Connection conn = null;

	public ProjectAbstract(Connection connection){
		conn = connection;
	}
	
	public HashSet<String> getAllProjectid() throws SQLException{
		PreparedStatement query = conn.prepareStatement(
				"SELECT DISTINCT projectid FROM projects;");
		ResultSet result = query.executeQuery();
		HashSet<String> ret = new HashSet<String>();
		while (result.next())
			ret.add(result.getString(1));
		System.out.println("Finished get all project id");
		return ret;
	}
	
	public HashMap<String, Object> getTotalSupportExclusive() throws SQLException{
		PreparedStatement query = conn.prepareStatement(
				"SELECT projectid, total_price_excluding_optional_support FROM projects");
		ResultSet result = query.executeQuery();
		HashMap<String, Object> ret = new HashMap<String, Object>();
		while (result.next())
			ret.put(result.getString(1), result.getDouble(2));
		System.out.println("finished getTotalSupportExclusive");
		return ret;
	}
}
